package org.dey.controller;

import org.dey.entity.Result;
import org.dey.pojo.PageVo;
import org.dey.pojo.RiskAssessment;
import org.dey.service.RiskAssessmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class RiskAssessmentController {
    @Autowired
    RiskAssessmentService riskAssessmentService;

    @GetMapping("raid.do/{raidd}")
    public RiskAssessment queryRaById(@PathVariable int raidd) {
        RiskAssessment raById = riskAssessmentService.queryRaById(raidd);
        return raById;
    }

    @PostMapping("addra.do")
    public Result addRa(@RequestBody RiskAssessment riskAssessment) {
        return riskAssessmentService.addRa(riskAssessment);
    }

    @DeleteMapping("delra.action/{raidd}")
    public Result deleteRa(@PathVariable int raidd) {
        Result result = riskAssessmentService.deleteRa(raidd);
        return result;
    }


    @PutMapping("updatera.action")
    public int updateRa(@RequestBody RiskAssessment riskAssessment) {
        return riskAssessmentService.updateRa(riskAssessment);
    }

    @PostMapping("queryRa.do/{pageNum}/{pageSize}")
    public PageVo<RiskAssessment> queryRa(@RequestBody RiskAssessment riskAssessment,
                                          @PathVariable Integer pageNum,
                                          @PathVariable Integer pageSize) {
        PageVo<RiskAssessment> list = riskAssessmentService.queryRa(riskAssessment, pageNum, pageSize);
        return list;
    }
}
